package com.usian.user.controller;

import com.usian.apis.user.ApUserRealnameControllerApi;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.user.RealNameConstans;
import com.usian.model.user.dtos.AuthDto;
import com.usian.user.service.ApUserRealnameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/realname")
public class ApUserRealnameController implements ApUserRealnameControllerApi {
    @Autowired
    ApUserRealnameService service;

    @Override
    @PostMapping("/list")
    public ResponseResult loadListByStatus(@RequestBody AuthDto dto) {
        return service.loadListByStatus(dto);
    }

    @Override
    @PostMapping("/pass")
    public ResponseResult authPass(@RequestBody AuthDto dto) {
        dto.setStatus(RealNameConstans.PASS_AUTH);
        return service.updateByRealId(dto);
    }

    @Override
    @PostMapping("/fail")
    public ResponseResult authFail(@RequestBody AuthDto dto) {
        dto.setStatus(RealNameConstans.FAIL_AUTH);
        return service.updateByRealId(dto);
    }
}
